#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper 'Dumper';
use Tie::IxHash;

tie my %data, 'Tie::IxHash';

while ( <DATA> ) {
    chomp;

    my ($k, $v) = split /=/;

    my @k = split /\./, $k;

    my $t = \%data;

    for (my $i = 0; $i < $#k; $i++) {
        unless ( exists $$t{ $k[$i] } ) {
            tie my %t2, 'Tie::IxHash';
            $$t{ $k[$i] } = \%t2;
        }
        $t = $$t{ $k[$i] };
    }

    $$t{ $k[-1] } = $v;
}

print Dumper(\%data);


__END__
id=www
session.timeout=120
session.server.0.host=127.0.0.1
session.server.0.port=1111
session.server.0.id=session1
session.server.1.host=127.0.0.1
session.server.1.port=1111
session.server.1.id=session2
image.width=640
image.height=480
image.watermark.small=wsmall.png
image.watermark.normal=wnormal.png

